package app;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

import data.ImageVisual;
import data.VectorVisual;
import data.visualizzation;

/**
 * Classe per scegliere le visualizzazioni.
 * 
 * @author TeamVulcan
 * 
 */

public class MenuVis extends JPanel {

	
	private static visualizzation vis=new VectorVisual();
	
	public static visualizzation getVis() {
		return vis;
	}

	public static void setVis(visualizzation vis) {
		MenuVis.vis = vis;
	}

	Container menuBar = new JPanel();

	public MenuVis() {
		super();
		createButton("Vectorial Visualization", new VectorVisual());
		createButton("Image Visualization", new ImageVisual());
		createButton("Back to Main Menu", null);
		createButton("Exit", null);
		menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.PAGE_AXIS));
		add(menuBar);
	}

	public void createButton(final String name, final visualizzation visual) {
		JButton button = new JButton(name);
		button.setAlignmentX(Component.CENTER_ALIGNMENT);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (name == "Exit") {
					GameFrame.getFrame().dispose();
				} else if (name == "Back to Main Menu") {
					GameFrame.getFrame();
					GameFrame.refreshMainMenu();
				} else {
					MenuVis.vis = visual;
					GameFrame.getFrame();
					GameFrame.refreshMainMenu();
				}
			}
		});
		menuBar.add(button);
	}
}